#!/usr/bin/python
# -*- coding: UTF-8 -*-

import dbus
import dbus.glib
import gobject

class HardwareMonitor: 

   def __init__(self):
      bus = dbus.SystemBus()
      obj = bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')
      hal = dbus.Interface(obj, 'org.freedesktop.Hal.Manager')

      hal.connect_to_signal('DeviceAdded', self.device_added)
      hal.connect_to_signal('DeviceRemoved', self.device_removed)

   def device_added(self, device):
      print '- dispositivo adicionado -'
      print device

   def device_removed(self, device):
      print '- dispositivo removido -'
      print device

if __name__ == '__main__':
   hm = HardwareMonitor()

   mainloop = gobject.MainLoop()
   mainloop.run()

